package com.cema.manage.config;
import com.cema.manage.common.utils.PropertiesUtils;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

@Configuration
@MapperScan(basePackages = "com.cema.manage.project.*.*.mapper", sqlSessionFactoryRef = "masterSqlSessionFactory")
public class MasterDbConfig extends MasterDb {
    private static String url;
    private static String username;
    private static String password;

    static {
        try {
            Properties ppt=    PropertiesUtils.getPropertyFile("application.properties");
            MasterDbConfig.url = ppt.getProperty( "spring.datasource.mastUrl");
            MasterDbConfig.username = ppt.getProperty("spring.datasource.mastUsername");
            MasterDbConfig.password = ppt.getProperty("spring.datasource.mastPasswd");

        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("加载配置文件异常");
        }

    }


    private static String packages="com.cema.manage.project.*.*.domain";

    private static String xmlPaths="classpath*:mybatis/*/*.xml";

    public MasterDbConfig(){
        super(url,username,password,packages,xmlPaths);
    }

}